#define DEBUG
#include <cstdio>
#include <cstdlib>

using namespace std;

const int maxn=200000, maxm=200000;

inline bool heapCmp(int *a, int x, int y) {
  return a[x]<=a[y];
}

inline void heapSwap(int *a, int *id, int x, int y) {
  int t;
  t=a[x], a[x]=a[y], a[y]=t;
  t=id[x], id[x]=id[y], id[y]=t;
}

void up(int *a, int *id, int o) {
  if (o>1 && heapCmp(a, o, o/2)) {
    heapSwap(a, id, o, o/2);
    up(a, id, o/2);
  }
}

void down(int *a, int *id, int o) {
  if (((o*2<a[0] && heapCmp(a, o*2, o*2+1)) || o*2==a[0]) && heapCmp(a, o*2, o)) {
    heapSwap(a, id, o*2, o);
    down(a, id, o*2);
  } else if ((o*2<a[0] && heapCmp(a, o*2+1, o*2)) && heapCmp(a, o*2+1, o)) {
    heapSwap(a, id, o*2+1, o);
    down(a, id, o*2+1);
  }
}

void ins(int *a, int *id, int x, int v) {
  a[++a[0]] = x;
  id[a[0]] = v;
  up(a, id, a[0]);
}

void del(int *a, int *id, int x) {
  a[x] = 0, id[x] = 0;
  heapSwap(a, id, x, a[0]);
  a[0]--;
  down(a, id, x);
}

void sort(int *a, int l, int r) {
  int i=l, j=r, mid=a[(l+r)/2], temp;
  for (; i<=j; ) {
    for (; a[j]>mid; j--);
    for (; a[i]<mid; i++);
    if (i<=j) {
      temp=a[i], a[i]=a[j], a[j]=temp;
      i++, j--;
    }
  }
  if (i<r) {
    sort(a, i, r);
  
}
  if (j>l) {
    sort(a, l, j);
  }
}

void sort(int *a, int *b, int l, int r) {
  int i=l, j=r, mid=a[(l+r)/2], temp;
  for (; i<=j; ) {
    for (; a[j]>mid; j--);
    for (; a[i]<mid; i++);
    if (i<=j) {
      temp=a[i], a[i]=a[j], a[j]=temp;
      temp=b[i], b[i]=b[j], b[j]=temp;
      i++, j--;
    }
  }
  if (i<r) {
    sort(a, b, i, r);
  }
  if (j>l) {
    sort(a, b, l, j);
  }
}

int main() {
  freopen("dream.in", "r", stdin);
  freopen("dream.out", "w", stdout);

  static int t[maxm+1], l[maxn+1], r[maxn+1];
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i=1; i<=n; i++) {
    scanf("%d %d", l+i, r+i);
  }
  sort(l, r, 1, n);
  for (int i=1; i<=m; i++) {
    scanf("%d", t+i);
  }
  sort(t, 1, n);

  int ans=0;
  static int a[maxn+1], id[maxn+1];
  for (int i=1, j=1; i<=m; i++) {
    for (; j<=n && l[j]<=t[i]; j++) {
      ins(a, id, r[j], j);
    }
    for (; a[0] && r[id[1]]<t[i]; del(a, id, 1)) {
    }
    if (a[0]) {
      ans++;
      del(a, id, 1);
    }
  }

  printf("%d", ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
